package com.zl.service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.system.comm.util.Snowflake;
import com.system.common.mapper.BisCustomUserMapper;
import com.system.common.mapper.BisOpinionMapper;
import com.system.common.pojo.BisCustomUser;
import com.system.common.pojo.BisOpinion;

@Service
public class ZlBisHomeServiceImpl implements ZlBisHomeService{
	
	@Autowired
	private BisCustomUserMapper bisCustomUserMapper;
	@Autowired
	private BisOpinionMapper bisOpinionMapper;
	@Override
	public BisCustomUser selectByPrimaryKey(String userId) {
		BisCustomUser customUserPO=bisCustomUserMapper.selectByPrimaryKey(userId);
		return null;
	}

	@Override
	public Map<String, Object> saveOpinion(String UserId, HttpServletRequest request) {
		
		String content=request.getParameter("content");
		Snowflake snowflake=new Snowflake(0, 0);
		String opinionId=snowflake.nextId()+"";
		BisOpinion bisOpinion=new BisOpinion();
		bisOpinion.setOpinionId(opinionId);
		bisOpinion.setCustomUserId(UserId);
		bisOpinion.setContent(content);
		bisOpinion.setCreateTime(new Date());
		int a=bisOpinionMapper.insert(bisOpinion);
		Map<String, Object> map=new HashMap<>();
		if (a>0) {
			map.put("state", "1");
			map.put("appmsg", "提交成功！！");
		}else {
			map.put("appmsg", "提交失败！！");
		}
		return map;
	}

}
